package controller;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Alex
 */

import com.dhtmlx.connector.ConnectorServlet;
import com.dhtmlx.connector.DBType;
import com.dhtmlx.connector.SchedulerConnector;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;



public class conexScheduler extends ConnectorServlet{

    private static Connection con;

    /**
     * @return the con
     */
    public void conectar() throws SQLException {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException ex) {
            throw new SQLException("Driver no cargado !!!"+ex.toString());
        }
        System.out.println("eeeeeeeeeeeee");
        setCon(DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","admin"));
    }

    /**
     * @param aCon the con to set
     */
    public static void setCon(Connection aCon) {
        con = aCon;
    }
    public  Connection getCon() {
        try {
            conectar();
        } catch (SQLException ex) {
            System.out.println("EXCEPTION SQL");
            Logger.getLogger(conexScheduler.class.getName()).log(Level.SEVERE, null, ex);
        } catch(Exception e){
            System.out.println("EXCEPTION GLOBAL");
        }
        return con;
    }

    @Override
    protected void configure() {  
        try{
            System.out.println("aaaaaaaaaaaa:"+getCon());
            if(this.getCon()!=null){
                SchedulerConnector c = new SchedulerConnector(getCon(), DBType.MySQL);
                c.enable_log("c:\\Logs\\archivo.log",true);
                c.render_table("events","event_id","start_date,end_date,details");
                System.out.println("cccccccccccccccc");
            }
        }catch(Exception e){
            System.out.println("esta jodio");
        }
    }
}
